/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package seso;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author Administrator
 */
class RCalendarCellRenderer implements TableCellRenderer {

    public static final DefaultTableCellRenderer DEFAULT_RENDERER =
            new DefaultTableCellRenderer();

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        Component renderer =
                DEFAULT_RENDERER.getTableCellRendererComponent(table, value,
                isSelected, hasFocus, row, column);
        Color foreground, background;

        Object day = table.getModel().getValueAt(row, column);
        if ((column == 0 || hasFocus || isSelected) && day != null) {
            foreground = Color.white;
            background = Color.gray;
        } else {
            foreground = Color.BLACK;
            background = Color.WHITE;
        }
        renderer.setForeground(foreground);
        renderer.setBackground(background);
        return renderer;
    }
}
